<%--
   help
   Copyright (c) 2013 ISPERP
   Version : 1.0.0
 --%>
<%@ tag language="java" pageEncoding="UTF-8"
	deferredSyntaxAllowedAsLiteral="false" trimDirectiveWhitespaces="true"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ attribute name="id" required="true" type="java.lang.String"
	description="唯一标识."%>
<%@ attribute name="fromId" type="java.lang.String"
	description="关联流程的FromId值,优先级高于ToId。"%>
<%@ attribute name="fromProcessKey" type="java.lang.String"
	description="关联流程的源流程类型。"%>
<%@ attribute name="toId" type="java.lang.String"
	description="关联流程的ToId值,优先级低于FromId。"%>

<script type="text/javascript">

	window.onload = relateIncident;
	function relateIncident() {
	
		var fid = '${fromId}';
		var toId = '${toId}';
		var fkey = '${fromProcessKey}';
		var tId = "";
		var tUrl = "";
		if (fid != null && fid != undefined && fid != "") {
			tId = fid;
			tUrl = "bpm/processRelation/getRelateMainProcessInfoByBpmProFromId";
		} else if (toId != null && toId != undefined && toId != "") {
			tId = toId;
			tUrl = "bpm/processRelation/getRelateMainProcessInfoByBpmProToId";
		}

		$.get(tUrl, {
			id : tId,
			fkey : fkey
		}, function(result) {
			if (result == "" || result == null)
				return false;
			var ftype = result.msg;
			switch (ftype) {
			case "incidentProcess":
				createIncidentMainInfo(result);
				break;
			case "changeProcess":
				createChangeMainInfo(result);
				break;
			default:
				break;
			}

		});

	}
	function createChangeMainInfo(result) {
		var requesterName = result.data.requester_name;
		var requestDate = result.data.request_date;
		var cusUserCode = result.data.cus_name;
		var cusUserTel = result.data.cus_tel == null ? "" : "/" + result.data.cus_tel;
		var requesterMail = result.data.cus_email;
		var chgCode = result.data.code;
		var requesterDept = result.data.cus_dep;
		var requesterPhone = result.data.cus_mobile == null ? "" : result.data.cus_mobile;
		var cusUserMobileShort = result.data.cus_mobile_short == null ? "" : "/" + result.data.cus_mobile;
		$("#requesterName").text(requesterName);
		$("#requestDate").text(requestDate);
		$("#requesterDept").text(requesterDept);
		$("#requesterMail").text(requesterMail);
		$("#requesterPhone").text(requesterPhone + cusUserMobileShort + cusUserTel);
		$("#chgCode").text(chgCode);
		$("#relateChgTable").show();
	}
	function createIncidentMainInfo(result) {
		var cusUserName = result.data.cus_fullname;
		var cusUserCode = result.data.cus_name;
		var cusUserTel = result.data.cus_tel;
		var icdCode = result.data.code;
		var cusUserMobile = result.data.cus_mobile == null ? "" : result.data.cus_mobile;
		var cusUserMobileShort = result.data.cus_mobile_short;
		var linkManName = result.data.linkman_name;
		var linkManPhone = result.data.linkman_phone;
		var ci_code = result.data.ci_code;
		var cusUserType = result.data.cus_type == null ? "" : result.data.cus_type;
		var cusUserEmail = result.data.cus_email;
		var cusUserPosition = result.data.cus_position;
		var cusUserDep = result.data.cus_dep;
		var creatorName = result.data.creator_name;
		var tempPhone = cusUserMobile;
		if (cusUserTel != undefined && cusUserTel != null)
			tempPhone = tempPhone + "/" + cusUserTel;
		if (cusUserName != null && cusUserName != undefined) {
			$("#cusUserName").text(cusUserName);
			$("#cusUserPhone").html(tempPhone);
			$("#cusUserType").text(cusUserType);
			$("#cusUserCode").text(cusUserCode);
			$("#cusUserDep").html(cusUserDep);
			$("#cusUserEmail").html(cusUserEmail);
			$("#linkManName").html(linkManName);
			$("#linkManPhone").html(linkManPhone);
			$("#creatorName").html(creatorName);
			$("#cusUserMobileShort").html(cusUserMobileShort);
			$("#ciCode").html(ci_code);
			$("#icdCode").html(icdCode);
			$("#relateIcdTable").show();
		}
	}
</script>
<table class="form-table" id="relateIcdTable" style="display:none">
	<tr>
		<td class="header" colspan="2">
			<h3>
				主单信息(&nbsp;事件单:<span id="icdCode"></span>)
			</h3>
		</td>
	</tr>
	<tr>
		<td class="td1" style="font-weight: 700;font-size: 14px">申报人：</td>
		<td class="td2"><label id="cusUserName"></label>（工号：<span
			id="cusUserCode"></span>）</td>
		<td class="td1">电话：</td>
		<td class="td2" id="cusUserPhone"></td>
	</tr>
	<!-- <tr>
		<td class="td1">用户类型：</td>
		<td class="td2"><label id="cusUserType"></label> |&nbsp;<label
			id="cusUserPosition"></label></td>
		<td class="td1">短号：</td>
		<td class="td2" colspan="3" id="cusUserMobileShort"></td>
	</tr> -->
	<tr>
		<td class="td1">所在部门：</td>
		<td class="td2" id="cusUserDep"></td>
		<td class="td1">邮件：</td>
		<td class="td2" id="cusUserEmail"></td>
	</tr>
	<tr>
		<td class="td1">联系人：</td>
		<td class="td2" id="linkManName"></td>
		<td class="td1">联系电话：</td>
		<td class="td2" colspan="3" id="linkManPhone"></td>
	</tr>
	<!-- <tr>
		<td class="td1">关联资产：</td>
		<td class="td2" id="ciCode" colspan="3"></td>
	</tr> -->
</table>

<table class="form-table" id="relateChgTable" style="display:none">
	<tr>
		<td class="header" colspan="2">
			<h3>
				主单信息(&nbsp;变更单:<span id="chgCode"></span>)
			</h3>
		</td>
	</tr>
	<tr>
		<td class="td1" style="font-weight: 700;font-size: 14px">变更申请人：</td>
		<td class="td2"><label id="requesterName"></label></td>
		<td class="td1">申请日期：</td>
		<td class="td2" id="requestDate"></td>
	</tr>
	<tr>
		<td class="td1">电话：</td>
		<td class="td2" id="requesterPhone"></td>
		<td class="td1">邮件：</td>
		<td class="td2" id="requesterMail"></td>
	</tr>
	<tr>

		<td class="td1" style="">所在部门：</td>
		<td class="td2" colspan="3"><label id="requesterDept"></label></td>
	</tr>

</table>








